//
//  ZLPAboutUsViewController.m
//  TangYi
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 赵连鹏. All rights reserved.
//

#import "ZLPAboutUsViewController.h"

@interface ZLPAboutUsViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain) UITableView *tableView;

@end

@implementation ZLPAboutUsViewController

- (void)dealloc{
    [_version release];
    [_tableView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"关于我们";
    
    [self createTableView];
    
    [self createHeadView];
    
}

- (void)createHeadView {
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT / 3)];
    self.tableView.tableHeaderView = headView;
    [headView release];
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT / 3)];
    image.image = [UIImage imageNamed:@"appStore.png"];
    [headView addSubview:image];
    [image release];
}

- (void)createTableView {
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    [_tableView release];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    self.tableView.separatorStyle = NO;
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
    }
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"糖衣是一个推荐美好事物的软件,用户也可以分享自己喜欢的事物,在这里,你可以发现各种不同的事物,也可以分享你所喜爱的物品.";
        cell.textLabel.numberOfLines = 0;
    } else if (indexPath.section == 1) {
        cell.textLabel.text = [NSString stringWithFormat:@"当前版本: %@", self.version];
    } else {
        cell.textLabel.text = @"478138950@qq.com";
    }
    
    return cell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 80;
    } else {
        return 24;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 30)] autorelease];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 34)];
        [view addSubview:label];
        [label release];
        label.text = @"产品描述";
        label.font = [UIFont systemFontOfSize:22];
        return view;
    } else if (section == 1) {
        UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 34)] autorelease];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 34)];
        [view addSubview:label];
        [label release];
        label.text = @"版本信息";
        label.font = [UIFont systemFontOfSize:22];
        return view;
    } else {
        UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 34)] autorelease];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 34)];
        [view addSubview:label];
        [label release];
        label.text = @"联系方式";
        label.font = [UIFont systemFontOfSize:22];
        return view;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 40;
    } else {
        return 34;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
